package com.itheima.stock.config;


import com.itheima.stock.pojo.vo.StockInfoConfig;
import com.itheima.stock.utils.IdWorker;
import com.itheima.stock.utils.ParserStockInfoUtil;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
@EnableConfigurationProperties({StockInfoConfig.class})     //开启对相关对象的加载
public class CommonConfig {


    /**
     * 密码加密
     * @return
     */
//    @Bean
//    public PasswordEncoder passwordEncoder(){
//        return new BCryptPasswordEncoder();
//    }

    @Bean
    public IdWorker idWorker(){
        /**
         * 参数1：机器ia
         * 参数2：机房id
         * 机房和机器编号一般由运维人员进行唯一性规则
         */
        return new IdWorker(1l,2l);
    }

    /**
     * 定义解析股票 大盘 外盘 个盘 板块相关信息的工具类bean
     * @param idWorker
     * @return
     */
    @Bean
    public ParserStockInfoUtil parserStockInfoUtil(IdWorker idWorker){
        return new ParserStockInfoUtil(idWorker);
    }

}
